// TODO: 背住

/**
 * @file luogu/4282/main.cpp
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @brief 求树上三个点x, y, z的LCA。
 * 先求两个较深的点的LCA记作a，再求a与另一个点的LCA
 * @version 1.0
 * @date 2022-05-02
 *
 * @copyright Copyright (c) 2022
 *
 **/
#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
int n, m, s, head[N], num, t, dep[N], f[N][30];
struct node {
  int to, next;
} a[N * 2];
inline void add(int from, int to) {
  num++;
  a[num] = {to, head[from]};
  head[from] = num;
}
void dfs(int son, int fa) {
  dep[son] = dep[fa] + 1;
  f[son][0] = fa;
  for (int i = 1; i <= t; ++i) f[son][i] = f[f[son][i - 1]][i - 1];

  for (int i = head[son]; i; i = a[i].next) {
    int k = a[i].to;
    if (k != fa) dfs(k, son);
  }
}
int lca(int x, int y) {
  if (dep[x] > dep[y]) swap(x, y);
  for (int i = t; i >= 0; --i) {
    if (dep[f[y][i]] >= dep[x]) y = f[y][i];
  }
  if (x == y) return x;
  for (int i = t; i >= 0; --i) {
    if (f[x][i] != f[y][i]) {
      x = f[x][i];
      y = f[y][i];
    }
  }
  return f[x][0];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  t = log2(n);
  for (int i = 1; i <= n - 1; ++i) {
    int xa, xb;
    cin >> xa >> xb;
    add(xa, xb);
    add(xb, xa);
  }
  dfs(1, 0);
  int q, w,  // 深度最深的LCA对应的两个点
      e,     // 另外一个点
      zx;    // 深度最深的LCA
  for (int i = 1; i <= m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    int l1 = lca(x, y), l2 = lca(x, z), l3 = lca(y, z);
    if (dep[l1] >= dep[l2] && dep[l1] >= dep[l3])
      q = x, w = y, e = z, zx = l1;
    else if (dep[l2] >= dep[l1] && dep[l2] >= dep[l3])
      q = x, w = z, e = y, zx = l2;
    else if (dep[l3] >= dep[l2] && dep[l3] >= dep[l2])
      q = z, w = y, e = x, zx = l3;

    int wdt = lca(q, e);  // 找到较浅的两个点的LCA
    int ans = dep[q] + dep[w] - 2 * dep[zx] + dep[e] + dep[zx] - 2 * dep[wdt];
    printf("%d %d\n", zx, ans);
  }
}
